<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('check表格页')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
	var prefix = ctx + "system/dept";
	var depts = eval([[${depts}]]);
	console.log(depts);
	$(function() {
		var options = {
			url: prefix + "/firstDeptList",
			showSearch: false,
			showRefresh: false,
			showToggle: false,
			showColumns: false,
			columns: [{
				checkbox: true,
				formatter:function (value, row, index) {
					for (var i = 0; i < depts.length; i++) {
						if (depts[i].deptId == row.deptId) {
							return { checked: true };
						}
					}
					return { checked: false };
				}
			},
			{
				field : 'deptId',
				title : '部门ID'
			},
			{
				field : 'deptName',
				title : '部门名称'
			}]
		};
		$.table.init(options);
	});

	/* 添加用户-选择用户-提交 */
	function submitHandler(index, layero) {
		var rows = $.table.selectFirstColumns();
		/*if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}*/

		console.log(rows.join());

		$.modal.close();
		// 父页面的方法
		parent.append([[${menuId}]],[[${perms}]],rows.join());
		// 父页面的变量
		// parent.$('#menuId').val();
		// parent.$('#perms').val();
		// parent.$('#deptIds').val();
	}
</script>
</body>
</html>